﻿using Pattern06原型模式.Helper;
using Pattern06原型模式.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.NetworkInformation;
using System.Text;
using System.Threading.Tasks;

namespace Pattern06原型模式.Models
{
    [Serializable]
    public class ApplePhone : IPhone
    {
        public ApplePhone()
        {
            Battery = new Battery
            {
                Capacity = 5000,
                Power = 5,
                Voltage = 3.7
            };
        }
        public string CPU { get; set; } = string.Empty;

        public int Memory { get; set; } = 0;
        public Battery Battery { get; set; }

        public IPhone Clone()
        {
            return this.MemberwiseClone() as ApplePhone;
        }

        public IPhone DeepClone()
        {
            SerializableHelper helper = new SerializableHelper();
            string target = helper.Serializable(this);
            return helper.Derializable<IPhone>(target);
        }

        public void Write(string tag)
        {
            Console.WriteLine($"{tag}=> CPU = {CPU},Memory = {Memory}");
        }
    }
}
